package com.lidy.tankbattle.tankgame2.wall;

import com.lidy.tankbattle.tankgame2.constant.WallPriorities;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author lidy
 * @version V1.0
 * @classname Wall
 * @description 墙体父类
 * @date 2022/6/5 10:25
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Wall {

    /**
     * 墙体编号
     **/
    private int number;

    /**
     * X坐标
    **/
    private int x;

    /**
     * Y坐标
     **/
    private int y;

    /**
     * 宽度
     **/
    private int width;

    /**
     * 高度
     **/
    private int height;

    /**
     * 类型
    **/
    private int type;

    /**
     * 血量
    **/
    private int bloodVolume;

    /**
     * 是否存在
    **/
    private Boolean exist = true;

    public Wall(int number ,int x, int y, int width, int height, int type, int bloodVolume) {
        this.number = number;
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
        this.type = type;
        this.bloodVolume = bloodVolume;
    }

    /**
     * @author: lidy
     * @description: 获取砖墙
     * @date: 2022/6/5 12:27
     */
    public static Wall getBrickWall(int number, int x, int y) {
       return new Wall(number, x, y, WallPriorities.WALL_WIDTH, WallPriorities.WALL_HEIGHT, WallPriorities.BRICK_WALL, (int)(Math.random() * WallPriorities.BRICK_WALL_MAX_BLOOD) + 1);
    }

    /**
     * @author: lidy
     * @description: 获取金属墙
     * @date: 2022/6/5 12:36
     */
    public static Wall getMetalWall(int number, int x, int y) {
        return new Wall(number, x, y, WallPriorities.WALL_WIDTH, WallPriorities.WALL_HEIGHT, WallPriorities.METAL_WALL, Integer.MAX_VALUE);
    }

    /**
     * @author: lidy
     * @description: 砖墙被子弹击中后血量减少
     * @date: 2022/6/7 20:41
     */
    public void reduceBlood(int value) {
        bloodVolume -= value;
        if (bloodVolume <= 0) {
            exist = false;
        }
    }
}
